package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.health.entity.TOrder;
import com.itheima.health.entity.TOrdersetting;
import com.itheima.health.entity.TSetmeal;
import com.itheima.health.entity.TSetmealCheckgroup;
import com.itheima.health.mapper.TSetmealCheckgroupMapper;
import com.itheima.health.pojo.vo.ReportVO;
import com.itheima.health.pojo.vo.SetmealReportVO;
import com.itheima.health.service.ITOrderService;
import com.itheima.health.service.ITOrdersettingService;
import com.itheima.health.service.ITSetmealCheckgroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.service.ITSetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cpanda
 * @since 2024-01-26
 */
@Service
public class TSetmealCheckgroupServiceImpl extends ServiceImpl<TSetmealCheckgroupMapper, TSetmealCheckgroup> implements ITSetmealCheckgroupService {
    @Autowired
    ITSetmealService setmealService;
    @Autowired
    ITOrderService orderService;
    @Override
    public SetmealReportVO getSetmealReport() {
        SetmealReportVO setmealReportVO = new SetmealReportVO();
        List<TSetmeal> setmealList = setmealService.list();
        List<String> list = new ArrayList<>();
        List<ReportVO>voList = new ArrayList<>();
        for (TSetmeal setmeal : setmealList) {
            list.add(setmeal.getName());
            ReportVO reportVO = new ReportVO();
            reportVO.setName(setmeal.getName());
            Integer count =orderService.countSetmal(setmeal.getId());
            reportVO.setValue(count);
            voList.add(reportVO);
        }
        setmealReportVO.setSetmealCount(voList);
        setmealReportVO.setSetmealNames(list);
        return setmealReportVO;
    }
}
